import React, {Component} from 'react';
import "./index.less"
import {AxioInstance} from "../../api/AxiosHelper";
import {GET_EXAM_TEST} from "../../api/APIURLDefine";
import { withRouter } from 'react-router-dom';

/*考试测评信息*/
interface ExamTestMessage {
    id?: number;//id
    examName?: string;//实验名称
    startTime?: string;//开始时间
    endTime?: string;//结束时间
    description: string;//描述
}

/*考试测评单元块*/
// @ts-ignore
@withRouter
class ExamAssessment extends Component<any, any> {
    constructor(props) {
        super(props);
        this.state = {
            data: []
        }
        
    }

    componentDidMount() {
        
        var params = new URLSearchParams(this.props.history.location.search);
        var id = 1;
        if (params.has("id")) {
            id = parseInt(params.get("id"));
        }
        AxioInstance.get(`${GET_EXAM_TEST}/${id}`).then((data: any) => {
            //(data);
            this.setState({data: data});
        });
    }

    render() {
        return (
            <div className="examBack">
                {
                    this.state.data.map((ele: ExamTestMessage, ind) => {
                        //console.log(ele);
                        return <div key={ind} className="examItem">
                            <div className="examHead">
                                {ele.examName}
                            </div>
                            <div className="examBody">
                                &nbsp;&nbsp; {ele.description}
                            </div>
                            <div className="examFoot">
                                考试时间:{ele.startTime}~{ele.endTime}
                            </div>
                        </div>
                    })
                }

            </div>
        );
    }
}

export default ExamAssessment;